package game.sprite.collision;

/**
 * This class implements the basic behavior of an ICollidable
 * when it collides with another collidable. The collidable
 * passed to this class in the constructor is altered when any
 * of the collide() methods are called.
 * 
 * @author Ben
 * @author Paul
 * 
 */

public abstract class CollisionBehavior {

    private ICollidable myCollidable;

    /**
     * Constructs a new Collision Behavior.
     * 
     * @param collidable The collidable that the behavior
     *        will influence.
     */
    public CollisionBehavior(ICollidable collidable) {
        myCollidable = collidable;
    }

    /**
     * If the exact instance of the ICollidable is unknown
     * the collidable whose behavior this class represents
     * will undergo a default collision, through a method
     * call to defaultCollision().
     * 
     * @param other This class represents the collision
     *        behavior for a particular collidable. When that
     *        collidable hits another collidable, this method
     *        is called.
     */

    // TODO Implement a better version of this, since the
    // collision should actually also depend on the
    // properties of WHAT myCollidable is colliding into.
    // i.e. the properties of the other parameter are
    // actually important.

    public void visit(ICollidable other) {
        defaultCollision(myCollidable);
    }


    /**
     * By default, if the other object's exact type is not
     * specified, let the objects pass through each other.
     * To change the default collision, this method should
     * be overriden.
     * 
     * @param collidable The Object that has been involved
     *        in the collision.
     */
    protected void defaultCollision(ICollidable collidable) {

    }

}
